#include "SchmidtCAM.h"

int main( int argc, char *argv[] ){

    int fd = open("/dev/mem", O_RDWR | O_SYNC);
    uint *ptr1 = mmap(NULL, 10, PROT_READ | PROT_WRITE, MAP_SHARED, fd, ADDR_GPIO_OUT);
    uint *gpio_reg      = ptr1;     // 0x41200000

    if( argc !=2 ){
        printf("> usage: %s opt\n", argv[0]);
        printf("> 0: power down AFE.\n");
        printf("> 1: power up AFE.\n");
        exit(0);
    }

    int opt = atoi(argv[1]);

    if( 0 == opt ){
        clrbit(*gpio_reg, BIT_AFE_PD_CTL);
    } else if( 1 == opt ){
        setbit(*gpio_reg, BIT_AFE_PD_CTL);
    } else {
        printf("> opt can only be 0 or 1.\n");
        exit(0);
    }

    munmap(ptr1,10);
    close(fd);

    return 0;
}